package com.zhx.freedom.say.diary.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.zhx.freedom.say.diary.rpc.service.RpcDiaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * 描述: 日志模块控制类
 *
 * @author 周浩西
 * @date 2019/4/111:18
 */
@RestController
@RequestMapping("/diary")
public class DiaryController {


    @Autowired
    private RpcDiaryService rpcDiaryService;

    @Autowired
    RestTemplate restTemplate;


    @GetMapping("/test/{userName}")
    @HystrixCommand(fallbackMethod = "fallBack")
    public String getNameByCloud(@PathVariable("userName")String userName){
        String s = rpcDiaryService.getNameByCloud(userName);
        return s;
    }


    public String fallBack(String userName) {
        return "系统错误!!!!";
    }
}
